package com.AdvancedDemos.继承;

public class 重写覆盖 {
    public static void main(String[] args) {

        Teacher t = new Teacher("不知道什么老师", 13);
        BaseTeacher bt = new BaseTeacher("孙雷", 38);
        WorkTeacher wt = new WorkTeacher("王嘉伟", 99);
        System.out.println(t.toString());
        System.out.println(bt.toString());
        System.out.println(wt.toString());
        t.teach();
        bt.teach();
        wt.teach();
    }
}

class Teacher {
    private String name;
    private int age;

    @Override
    public String toString() {
        return "{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public Teacher(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void teach() {
        System.out.println("老师上课");
    }
}

class BaseTeacher extends Teacher {
    public BaseTeacher(String name, int age) {
        super(name, age);
    }

    @Override
    public void teach() {
        System.out.println("基础班老师上课");

    }
}

class WorkTeacher extends Teacher {
    public WorkTeacher(String name, int age) {
        super(name, age);
    }

    @Override
    public void teach() {
        System.out.println("就业班老师上课");
    }
}

